package com.kk.command;

public class RemoteController {
    private Command[] onCommandArr;
    private Command[] offCommandArr;
    private Command lastButton;

    public RemoteController() {
        onCommandArr = new Command[3];

        onCommandArr[0] = new DvdOnCommand();
        onCommandArr[1] = new LightOnCommand();
        onCommandArr[2] = new TvOnCommand();

        offCommandArr = new Command[3];
        offCommandArr[0] = new DvdOffCommand();
        offCommandArr[1] = new LightOffCommand();
        offCommandArr[2] = new TvOffCommand();
    }

    /**
     * 开按钮
     *
     * @param number
     */
    public void turnOnButton(int number) {
        onCommandArr[number].execute();
        lastButton = onCommandArr[number];
    }

    /**
     * 关按钮
     *
     * @param number
     */
    public void turnOffButton(int number) {
        offCommandArr[number].execute();
        lastButton = offCommandArr[number];
    }


    /**
     * 撤销按钮
     */
    public void undoButton() {
        lastButton.undo();
    }
}
